package com.tobeface.wechat.request.api;

import com.tobeface.modules.lang.Requires;
import com.tobeface.wechat.request.AbstractWeChatApiRequestBuilder;
import com.tobeface.wechat.request.WeChatRequest;

/**
 * @author loudyn
 */
public class GetUserInfoApiRequestBuilder extends AbstractWeChatApiRequestBuilder {

    private String openId;
    private String lang;

    /**
     *
     */
    public GetUserInfoApiRequestBuilder() {
        super("https://api.weixin.qq.com/cgi-bin/user/info", WeChatRequest.Verb.GET);
    }

    /**
     *
     * @param openId
     * @return
     */
    public GetUserInfoApiRequestBuilder withOpenId(String openId) {
        Requires.hasText(openId);
        this.openId = openId;
        return this;
    }

    /**
     *
     * @return
     */
    public GetUserInfoApiRequestBuilder usingCNLang() {
        this.lang = "zh_CN";
        return this;
    }

    /**
     *
     * @return
     */
    public GetUserInfoApiRequestBuilder usingTWlang() {
        this.lang = "zh_TW";
        return this;
    }

    /**
     *
     * @return
     */
    public GetUserInfoApiRequestBuilder usingENLang() {
        this.lang = "en";
        return this;
    }

    @Override
    protected void configRequest(WeChatRequest request) {
        request.addQueryParam("openid", openId).addQueryParam("lang", lang);
    }
}
